#ifndef BASE_LOG_H
#define BASE_LOG_H

// ! Define log levels
#define LOG_LEVEL_FATAL     0
#define LOG_LEVEL_ERROR     1
#define LOG_LEVEL_WARN      2
#define LOG_LEVEL_NOTICE    3   
#define LOG_LEVEL_INFO      4   
#define LOG_LEVEL_DEBUG     5   
#define LOG_LEVEL_TRACE     6 

// ! Module ID
#ifndef LOG_MODULE_ID
#define LOG_MODULE_ID   "???"
#endif

// ! Define commonly macros

#define LogPrintf(level, fmt, ...) \
    LogPrintfFunc(LOG_MODULE_ID, __func__, __FILE__, __LINE__, level, true, fmt, ## __VA_ARGS__)

#define LogPuts(level, text) \
    LogPrintfFunc(LOG_MODULE_ID, __func__, __FILE__, __LINE__, level, false, text)

#define LogFatal(fmt, ...)  LogPrintf(LOG_LEVEL_FATAL,  fmt, ## __VA_ARGS__)
#define LogErr(fmt, ...)    LogPrintf(LOG_LEVEL_ERROR,  fmt, ## __VA_ARGS__)
#define LogWarn(fmt, ...)   LogPrintf(LOG_LEVEL_WARN,   fmt, ## __VA_ARGS__)
#define LogNotice(fmt, ...) LogPrintf(LOG_LEVEL_NOTICE, fmt, ## __VA_ARGS__)
#define LogInfo(fmt, ...)   LogPrintf(LOG_LEVEL_INFO,   fmt, ## __VA_ARGS__)

// LogInfo("xxxxxx fd=3")
// LogInfo("xxxxxx fd=4")
// logger.getter("xxxx")  .Info("日志内容")
// logger.getter("yyyy")  .Info("日志内容") 

#define LogUndo() LogPuts(LOG_LEVEL_NOTICE, "!!! Undo !!!")
//....

#ifdef __cplusplus
extern "C" {
#endif

void LogPrintfFunc(const char *module_id, const char* func_name, const char* file_name, 
                   int line, int level, bool with_args, const char *fmt, ...);

#ifdef __cplusplus
}
#endif

#endif